import requests


# 2.创建封装员工管理模块的类
import app


class EmpApi:

    def __init__(self):
        self.url_emp_all =app.BASE_HOSE +"/api/sys/user"
        self.url_emp_sample = app.BASE_HOSE + "/api/sys/user/{}"
    #封装添加员工接口
    def add_emp(self,token,json_dict):
        header_dict = {"Authorization":token}
        return requests.post(url=self.url_emp_all,headers=header_dict,json=json_dict)

    #封装查询员工接口
    def query_emp(self,token,emp_id):
        header_dict = {"Authorization": token}
        return requests.get(url=self.url_emp_sample.format(emp_id),headers=header_dict)


    #封装修改员工接口
    def update_emp(self,token,json_dict,emp_id):
        header_dict = {"Authorization": token}
        return requests.put(url=self.url_emp_sample.format(emp_id), json=json_dict,headers=header_dict)


    #封装删除员工接口
    def del_emp(self,token,emp_id):
        header_dict = {"Authorization": token}
        return requests.delete(url=self.url_emp_sample.format(emp_id), headers=header_dict)